package org.tgcloud.group.web.controller.manager;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;
import org.tgcloud.group.core.APPResultMessage;
import org.tgcloud.group.core.custom.Permissions;
import org.tgcloud.group.core.session.Session;
import org.tgcloud.group.entity.MjMediumOffline;
import org.tgcloud.group.service.manager.MediumManageService;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author: zhy
 * @create: 2023-11-10 10:22
 * @description: 媒体管理
 */
@Api(tags = "媒体管理相关接口")
@RestController
@RequestMapping("/manager/pc/user")
@EnableAutoConfiguration
public class MediumManageController extends ManageAPPBaseController{

    @Autowired
    private MediumManageService mediumManageService;


    @Permissions("medium:view")
    @ApiOperation(value = "媒体线上列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/getMediumOnlineList", method = RequestMethod.POST)
    public APPResultMessage getMediumOnlineList(@ModelAttribute("session") Session session,
                                            @RequestParam(required = false) Integer pageNum,
                                            @RequestParam(required = false) Integer pageSize,
                                            @RequestParam(required = false) String keyword,
                                            @RequestParam(required = false) Integer userType){
        return mediumManageService.getMediumOnlineList(pageNum, pageSize, keyword, userType, session.getComId());
    }


    @Permissions("medium:view")
    @ApiOperation(value = "媒体线下列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/getMediumOfflineList", method = RequestMethod.POST)
    public APPResultMessage getMediumOfflineList(@ModelAttribute("session") Session session,
                                                @RequestParam(required = false) Integer pageNum,
                                                @RequestParam(required = false) Integer pageSize,
                                                @RequestParam(required = false) String keyword,
                                                @RequestParam(required = false) Integer offlineType,
                                                 @RequestParam(required = false) Integer excelShowTitleId,
                                                 @RequestParam(required = false) Short status){
        return mediumManageService.getMediumOfflineList(pageNum, pageSize, keyword, offlineType, status, excelShowTitleId, session.getComId());
    }


    @Permissions("medium:addOnline")
    @ApiOperation(value = "新增线上媒体")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doAddOnlineMedium", method = RequestMethod.POST)
    public APPResultMessage doAddOnlineMedium(@ModelAttribute("session") Session session,
                                              @RequestParam Integer userType,
                                              @RequestParam String plateName,
                                              @RequestParam String fans,
                                              @RequestParam(required = false) BigDecimal cost,
                                              @RequestParam(required = false) BigDecimal goodPrice,
                                              @RequestParam(required = false) String remark,
                                              @RequestParam(required = false) String createType,
                                              @RequestParam(required = false) String steadyContent,
                                              @RequestParam(required = false) String pic,
                                              @RequestParam(required = false) String oneInteractionNum,
                                              @RequestParam(required = false) String oneExposureNum){
        return mediumManageService.doAddOnlineMedium(userType, plateName, fans, cost, goodPrice, remark, createType,
                steadyContent, pic, oneInteractionNum, oneExposureNum);
    }


    @Permissions("medium:addOffline")
    @ApiOperation(value = "新增线下媒体")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doAddOfflineMedium", method = RequestMethod.POST)
    public APPResultMessage doAddOfflineMedium(@ModelAttribute("session") Session session,
                                               @RequestBody MjMediumOffline offline){
        return mediumManageService.doAddOfflineMedium(offline);
    }


    @Permissions("medium:updateOnline")
    @ApiOperation(value = "修改线上媒体")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doUpdateOnlineMedium", method = RequestMethod.POST)
    public APPResultMessage doUpdateOnlineMedium(@ModelAttribute("session") Session session,
                                                 @RequestParam(required = false) Integer userType,
                                                 @RequestParam(required = false) String plateName,
                                                 @RequestParam(required = false) String fans,
                                                 @RequestParam(required = false) BigDecimal cost,
                                                 @RequestParam(required = false) BigDecimal goodPrice,
                                                 @RequestParam(required = false) String remark,
                                                 @RequestParam(required = false) String createType,
                                                 @RequestParam(required = false) String steadyContent,
                                                 @RequestParam(required = false) String pic,
                                                 @RequestParam int id,
                                                 @RequestParam(required = false) String oneInteractionNum,
                                                 @RequestParam(required = false) String oneExposureNum){
        return mediumManageService.doUpdateOnlineMedium(userType, plateName, fans, cost, goodPrice, id, remark,
                createType, steadyContent, pic, oneInteractionNum, oneExposureNum);
    }


    @Permissions("medium:updateOffline")
    @ApiOperation(value = "修改线下媒体")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doUpdateOfflineMedium", method = RequestMethod.POST)
    public APPResultMessage doUpdateOfflineMedium(@ModelAttribute("session") Session session,
                                               @RequestBody MjMediumOffline offline){
        return mediumManageService.doUpdateOfflineMedium(offline);
    }

    @Permissions("medium:delOnline")
    @ApiOperation(value = "删除线上媒体")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doDelOnlineMedium", method = RequestMethod.POST)
    public APPResultMessage doDelOnlineMedium(@ModelAttribute("session") Session session,
                                              @RequestParam int id){
        return mediumManageService.doDelOnlineMedium(id);
    }

    @Permissions("medium:delOffline")
    @ApiOperation(value = "删除线下媒体")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/doDelOfflineMedium", method = RequestMethod.POST)
    public APPResultMessage doDelOfflineMedium(@ModelAttribute("session") Session session,
                                              @RequestParam int id){
        return mediumManageService.doDelOfflineMedium(id);
    }



    @ApiOperation(value = "获取线下媒体级联数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/getMediumOfflineCascader", method = RequestMethod.POST)
    public APPResultMessage getMediumOfflineCascader(){
        return mediumManageService.getMediumOfflineCascader();
    }


}
